<?php
namespace app\index\controller;
use think\Controller;

class Term extends Controller
{
    /**
     * 首页显示所有栏目
     */
	
    public function gettermlist()
    {
        $termModel = D('Term');
        $list = $termModel->getTermList();
		$this->view->assign('list',$list);
		return $this->view->fetch('index/index'); 
    }
	
	//显示一级栏目信息(parent)
	public function getparent()
    {
        $termModel = D('Term');
        $list = $termModel->getTermChild('0');
		return $this->fetch('index/'.$tpl);
    }	

    /**
     * 显示栏目页
     */
    public function term()
    {
        $id = I('get.id');
        $termModel = D('Term');
        $info = $termModel->getInfo($id);
        if(empty($info))
            return $this->index();
        $termModelModel = D('TermModel');
        $tpl = $termModelModel->getTpl($info['type'], 'term');
        if(empty($tpl))
            return $this->index();
        $this->assign('termInfo', $info);
        return $this->fetch('index/'.$tpl);
    }

    /**
     * 显示内容页
     */
    public function content()
    {
        $id = I('get.id');
        $cid = I('get.cid');
        $info = $termModel->getInfo($id);
        if(empty($info))
            return $this->index();
        $tpl = $termModelModel->getTpl($info['model_id'], 'content');
        if(empty($tpl))
            return $this->index();
        $this->assign('termInfo', $info);
        return $this->fetch('index/'.$tpl);
    }
}
